Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deApi_Private.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deApi_Private.hpp
00003 ///
00004 /// @brief DestinyEdit API, private header
00005 ///
00006 /// @author jwvanderbeck
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date Mar 2003
00023 /// @author jwvanderbeck
00024 /// @remarks Creation
00025 ///
00026 ///////////////////////////////////////////////////////////////////////////////
00027 
00028 //
00029 // Utility Macros
00030 //
00031 #ifdef _DEBUG
00032 #define DBGOUT(text)\
00033     TheApi.DebugOut(text);
00034 #else
00035 #define DBGOUT(text)
00036 #endif
00037 //
00038 // deApi
00039 //
00040 // Essentially, the main API manager.
00041 // deApi is a Singleton
00042 // ************************************************************************************
00043 // IMPORTANT: Plugins should never, ever, call this class directly, and it should never
00044 // be instantiated by anyone outside of the system itself!
00045 // ************************************************************************************
00046 //
00047 // ************************************************************************
00048 // IMPORTANT: This singleton class will be moved BEHIND the scenes, and not
00049 // exposed to the public api (not even the definition).
00050 // It will be used internally only.
00051 // ************************************************************************
00052 class deApi
00053 {
00054     friend class deApiHandle;
00055 
00056     public:
00057 
00058         //
00059         // This function really inits the whole ball of wax and is very important!
00060         bool InitApi(HWND hWindow);
00061         //
00062         // Determine the next available runtime ID
00063         unsigned long GetNextRuntimeID();
00064         //
00065         // Get a handle to the Node Tree.  Never call directly.  Use deApiFn_NodeTree
00066         deApiHandle GetNodeTree();
00067         //
00068         // These methods are used by function sets in order to create
00069         // the objects they will work on.
00070         deApiHandle CreateObject(deApiObject* pObject);
00071         bool DestroyObject(unsigned long runtimeID);
00072         //
00073         // Access to the underlying window handle
00074         HWND GetWindowHandle() { return m_hWindow; }
00075         //
00076         // Exchange a handle for an object pointer
00077         deApiObject* GetObjectFromHandle(deApiHandle handle);
00078         //
00079         // Output some text to the API's default output window
00080         // This is only active in debug mode
00081         void DebugOut(const deString& sText);
00082 //  private:
00083         //
00084         // These are marked private for now.  There should be no reason
00085         // to make them available to derived classes.
00086         //
00087         //
00088         // The ID stuff needs to be updated to allow reuse of destroyed IDs
00089         //
00090         unsigned long           runtimeID;  // Next runtime ID to be assigned
00091         deApiNodeTree*          m_pNodeTree; // The one and only node tree class
00092         deApiRender*            m_pRender;
00093         HWND                    m_hWindow;
00094         unsigned long           m_iOutputWindow;
00095 };
00096 //
00097 // Access to deApi singleton - VERY IMPORTANT!!!
00098 //
00099 #define TheApi deApi_GetManager()
00100 
00101 //
00102 // Api Objects
00103 //
00104 //
00105 // deApiObject
00106 //
00107 // Essentially, the root of the object side of the house.  This class in its base form
00108 // really doesn't do much at all, but it is the base from which all api objects are built 
00109 // on.  
00110 // This class should never be instantiated by anyone.
00111 class deApiObject
00112 {
00113     public:
00114         deApiObject();
00115         virtual ~deApiObject();
00116 
00117         DECLARE_RTI;
00118 /*      virtual deApiTypes::FunctionSet GetApiFnType();
00119         virtual deApiTypes::ObjectType GetApiObjectType();
00120         virtual bool CanUseApiFnSet(deApiTypes::FunctionSet fnType);*/
00121 
00122         virtual bool IsNull();
00123 
00124         virtual unsigned long GetRuntimeID();
00125         virtual unsigned long GetGlobalIDPrefix();
00126         virtual unsigned char GetGlobalID();
00127         // debug routines - will probably remove these once everything is working smoothly
00128         virtual void DumpObject();
00129         virtual int GetReferenceCount();
00130         virtual void RemoveReference();
00131         virtual void AddReference();
00132     
00133     protected:
00134         bool                    bNull;
00135         int                     iReferenceCount;
00136 };
00137 DECLARE_RTI_BASE(deApiObject);
00138 //
00139 // deApiNodeTree
00140 //
00141 // Provides a means for locating nodes within the tree, walking the tree,
00142 // and other misc access routines against the tree itself.  Does not
00143 // deal with nor encompass any specific nodes.
00144 class deApiNodeTree : public deApiObject
00145 {
00146     //
00147     // deApi is a friend here to allow it to access the methods to create
00148     // nodes which are hidden from the public for safety
00149     friend class deApi;
00150     //
00151     // deApiHandle is a friend to allow direct lookups of the api objects
00152     // instead of handles.  Only deApiHandle should ever be doing these
00153     // direct lookups
00154     friend class deApiHandle;
00155     friend class deApiFn;
00156     //
00157     public:
00158         //
00159         // Retrieves a handle to the object with the specified runtime ID
00160         deApiHandle GetNode(unsigned long runtimeID);
00161       //
00162       // Retrieves an array of runtime ids with configurable filters
00163       void GetNodes(deTArray<unsigned long>& aReturn, deString& TypeFilter = deString(""), int iMaxCount = -1);
00164         //
00165         // Default Constructor
00166         deApiNodeTree();
00167         //
00168         // Default Destructor
00169         ~deApiNodeTree();
00170         //
00171         DECLARE_RTI;
00172         // Function Set and Object Type defs
00173 //      FN_DEF(fnNodeTree)
00174 //      OT_DEF(otNodeTree)
00175     private:
00176         //
00177         // Inserts the specified object pointer into the tree's array.
00178         // The new runtime ID for the node will be returned, with 0 indicating a failure
00179         // If the array is not large enough, it will automaticly
00180         // be resized.
00181         unsigned long AddNode(deApiObject* pNewObject);
00182         //
00183         // Removes the specified node and destroys the underlying object
00184         bool DestroyNode(unsigned long runtimeID);
00185         //
00186         // Returns the actual underlying api object for a given runtime ID
00187         // This is used by deApiHandle and deApi, and no one else should ever be doing
00188         // this de-reference.
00189         deApiObject* GetApiObject(unsigned long runtimeID);
00190     //
00191     private:
00192         deTArray<deApiObject*>  m_tarrayNodes;
00193         deTArray<unsigned long> m_runtimeIDs;
00194 //      deTList<unsigned long>  m_runtimeIDs;
00195 };
00196 DEFINE_RTI(deApiNodeTree,deApiObject);
00197 //
00198 // deApiNode
00199 //
00200 // Root class for any api object which is a node (Which is most, but not all api objects)
00201 // This root class provides the basic common functions all nodes need.
00202 class deApiNode : public deApiObject
00203 {
00204     public:
00205         deApiNode() {};
00206         ~deApiNode() {};
00207         DECLARE_RTI;
00208 };
00209 DEFINE_RTI(deApiNode,deApiObject);
00210 //
00211 // deApiStaticBrush
00212 //
00213 // Represents a StaticBrushNode, which is a specific type of node that
00214 // generates a Destiny3D StaticBrush.
00215 class deApiStaticBrush : public deApiNode
00216 {
00217     DECLARE_RTI;
00218 };
00219 DEFINE_RTI(deApiStaticBrush,deApiNode);
00220 //
00221 // deApiAttribute
00222 //
00223 // Represents a single specific attribute, which could be either an input or output
00224 // attribute on a node.  This is the base attribute class and should not be used
00225 // directly.  Instead, a derived class covering the specific attribute type should
00226 // be used.
00227 class deApiAttribute: public deApiObject
00228 {
00229     public:
00230         enum Type
00231         {
00232             Invalid = 0,
00233             Float,
00234             Int,
00235             Vector,
00236             Bool,
00237             Color_RGB,
00238             Color_Alpha,
00239             Color_RGBA,
00240             UV,
00241             UVW,
00242             Transform,
00243             OutOfRange = 65535
00244         };
00245         deApiAttribute();
00246         ~deApiAttribute();
00247         Type GetAttributeType();
00248         unsigned long GetRuntimeID();
00249         //
00250         // Function Set and Object Type defs
00251 //      DECLARE_RTI;
00252 //      FN_DEF(fnAttribute)
00253 //      OT_DEF(otAttribute)
00254     protected:
00255         unsigned long   runtimeID;
00256 };
00257 //DEFINE_RTI(deApiAttribute,deApiObject);
00258 //
00259 // deApiAttribute_Float
00260 //
00261 // A float attribute.  See base class deApiAttribute for more information on attributes.
00262 class deApiAttribute_Float : public deApiAttribute
00263 {
00264     public:
00265         deApiAttribute_Float();
00266         ~deApiAttribute_Float();
00267         Type GetAttributeType();
00268         void DumpObject();
00269 //      DECLARE_RTI;
00270     private:
00271         float   data;
00272 };
00273 //DEFINE_RTI(deApiAttribute_Float,deApiAttribute);
00274 //
00275 // deApiAttributeCollection
00276 //
00277 // Collection of attributes which is then applied as either the "inputs" or "outputs" for a node.
00278 // A node can only have a single collection for each.
00279 class deApiAttributeCollection : public deApiObject
00280 {
00281     public:
00282         deApiAttributeCollection();
00283         ~deApiAttributeCollection();
00284 
00285         DECLARE_RTI;
00286 /*      deApiTypes::FunctionSet GetApiFnType();
00287         deApiTypes::ObjectType GetApiObjectType();
00288         bool CanUseApiFnSet(deApiTypes::FunctionSet fnType);*/
00289 
00290         bool IsNull();
00291 
00292         unsigned short GetAttributeCount();
00293         deApiObject* GetAttribute(unsigned long runtimeID);
00294         void DumpObject();
00295 
00296         bool AddAttribute(deApiObject* pAttribute);
00297     private:
00298         // Array of bound individual attributes in this collection
00299         deTArray<unsigned long>     m_tarrayAttributes;
00300 };
00301 DEFINE_RTI(deApiAttributeCollection,deApiObject);
00302 //
00303 // deApiOutputWindow
00304 //
00305 // Instance of a standard output/log window
00306 class deApiOutputWindow : public deApiObject
00307 {
00308     public:
00309         //
00310         // default constructor
00311         deApiOutputWindow();
00312         //
00313         // default destructor
00314         ~deApiOutputWindow();
00315         //
00316         // Create the output window
00317         deApiTypes::StatusCode CreateOutputWindow(int x, int y, int width, int height, const char* title, bool bSizeable = true, bool bCaption = true);
00318         //
00319         // Destroy the output window
00320         void DestroyOutputWindow() { if(m_hWindow) DestroyWindow(m_hWindow); }
00321         //
00322         // Retrieve the window handle
00323         HWND GetWindowHandle() { return m_hWindow; }
00324         //
00325         // Add text to the log
00326         void AddLogText(const deString& text);
00327         //
00328         // Hide of Show the window
00329         void Hide(bool bHide);
00330         //
00331         // Get the contents of the window
00332         deString GetLogText();
00333         //
00334         // Function Set and Object Type defs
00335         DECLARE_RTI;
00336 //      FN_DEF(fnOutputWindow)
00337 //      OT_DEF(otOutputWindow)
00338     private:
00339         HWND        m_hWindow;
00340         deString    m_sText;
00341 };
00342 DEFINE_RTI(deApiOutputWindow,deApiObject);
00343 //
00344 // deApiRender
00345 //
00346 // Encapsulates the render and driver subsystems
00347 // Most of this is used internally.  The API will automaticlly handle
00348 // setup and rendering.  The controlling application just needs to call an
00349 // update once per frame.
00350 class deApiRender : public deApiObject
00351 {
00352     DECLARE_RTI;
00353     public:
00354         bool Init(deString& sDriverName);
00355         void BeginFrame();
00356         void EndFrame();
00357         void Render();
00358         void SetState();
00359     private:
00360         IdeRender*      m_pRender;
00361         IdeDriver*      m_pDriver;
00362 };
00363 DEFINE_RTI(deApiRender, deApiObject);
00364 //
00365 // deApiCamera
00366 //
00367 // Camera controls
00368 class deApiCamera : public deApiObject
00369 {
00370     DECLARE_RTI;
00371    public:
00372       deApiCamera();
00373       virtual ~deApiCamera();
00374 
00375         void SetFOV(deDouble dDegrees);
00376         void SetOrthoWidth(deDouble dWidth);
00377         void EnableOrtho(bool bEnable);
00378         deTransform GetTransform();
00379         void SetTransform(deTransform transform);
00380         void SetName(const deString& sName);
00381         deString& GetName();
00382         deDouble GetFOV();
00383         deDouble GetOrthoWidth();
00384         bool IsOrtho();
00385         deDouble GetNearClip();
00386         deDouble GetFarClip();
00387         void SetClip(deDouble dNear, deDouble dFar);
00388       IdeCamera* GetDestinyCamera();
00389    private:
00390       IdeCamera*     m_pCamera;
00391       deString       m_sName;
00392       deDouble       m_dFOV;
00393       deDouble       m_dOrthoWidth;
00394       bool           m_bIsOrtho;
00395       deDouble       m_dNearClip;
00396       deDouble       m_dFarClip;
00397       deTransform    m_Transform;
00398 };
00399 DEFINE_RTI(deApiCamera, deApiObject);

Generated on Mon Sep 12 19:58:22 2005 for Destiny3D by doxygen1.3-rc3